<?php

//echo br(3); ###########################################################################################

	$TEMP->set_file(array('handle' => DIR_VIEW_REGISTRAR . 'studentsEnrollment.html'));
	
	$STUDID		= _GET('studid');
	$REDIRECT	= _GET('r');
	$HASH		= _GET('hash');
	
	$getStudentInformation 		= $STUD->getStudentInformation($STUDID);
	$getFreshmenSemesterLinker 	= $DSC->getFreshmenSemesterLinker($getStudentInformation['course_idFK']);
	$stud_idPK 			= $getStudentInformation['stud_idPK'];
	$stud_no 			= $getStudentInformation['stud_no'];
	$first_name 		= $getStudentInformation['first_name'];
	$middle_name 		= $getStudentInformation['middle_name'];
	$last_name 			= $getStudentInformation['last_name'];
	$course_idFK 		= $getStudentInformation['course_idFK'];
	$course_desc 		= $getStudentInformation['course_desc'];
	$dept_desc 			= $getStudentInformation['dept_desc'];
	$course_desc 		= $getStudentInformation['course_desc'];
	$course_desc 		= $getStudentInformation['course_desc'];
	$sem_desc 			= $getFreshmenSemesterLinker['sem_desc'];
	$sem_linker_idPK 	= $getFreshmenSemesterLinker['sem_linker_idPK'];
	
	if ( isset($_POST['subButton']) ) {
		
		$if_error		= 0;
		
		$active_subj_taken	= _POST('active_subj_taken');
		$listsubjtaken	 	= _POST('list_subj_taken');
		$year_id	 		= _POST('year_id');
		
		if ( empty($listsubjtaken) ) { $if_error++; }

		if ( $if_error == 0 ) {
			$expListsubjtaken = explode(', ', $listsubjtaken);
			$studSubjEnrollID = $STUD->getInsertStudSubjEnrollID($stud_idPK, $course_idFK, $activeYear, $expListsubjtaken, $active_subj_taken, $sem_linker_idPK);
			redirect('?page=Students');
		}
		
	}
	else {
		$recordSaved = '0';
	}

	$TEMP->set_var(array('stud_id'			=> $stud_idPK,
						 'stud_no'			=> $stud_no,
						 'first_name'		=> $first_name,
						 'middle_name'		=> $middle_name,
						 'last_name'		=> $last_name,
						 'course_id'		=> $course_idFK,
						 'course_desc'		=> $course_desc,
						 'dept_desc'		=> $dept_desc,
						 
						 'sem_desc'			=> $sem_desc,
						 'sem_linker_id'	=> $sem_linker_idPK,
						 
						 'total_subj_unit'	=> $totalSubjUnit,
						 
						 'reg_sub_menu'		=> $pageLib->registrarSubMenu(DIR_IMAGES),
						 
						 'redirect'			=> $REDIRECT,
						 'hash'				=> $HASH,
						 
						 'record_saved'		=> $recordSaved,
						 'active_subj_taken'=> $active_subj_taken,
						));
?>